object LibraryErrorDemo extends App {
  var availableCopies = 3
  var borrowedCount = 0
  var continueBorrowing = true
  while (continueBorrowing && borrowedCount < availableCopies) {
    if (borrowedCount < availableCopies) {
      borrowedCount += 1
      println (s" 已借 $borrowedCount 本")
    } else {
      println("达到最大借阅数量")
      continueBorrowing = false
    }
    var renewCount = 0
    do {
      println(s"续借 $renewCount 次 ")
      renewCount += 1
    } while (renewCount < 2)
    continueBorrowing = borrowedCount < availableCopies / 2
  }
  var overdueDays = 10
  var fine = 0.0
  while (overdueDays> 0) {
    fine += 0.5
    overdueDays -= 1
  }
  println (f"罚款 $fine%.2f 元")
}